Skip to content

Auto-log parallelism info to wandb.config using HF Accelerate - #40055

Closed
WoosungMyung wants to merge 1 commit into
huggingface:mainfrom
WoosungMyung:feat/wandb-parallelism-config
Closed

WoosungMyung wants to merge 1 commit into
huggingface:mainfrom
WoosungMyung:feat/wandb-parallelism-config

Conversation

@WoosungMyung

Copy link
Copy Markdown

What

This PR adds parallelism info non intrusively to WandbCallback so that, when Hugging Face Accelerate is in use, the callback automatically logs the parallelism sizes to wandb.config at train start.

Why

Users frequently want their distributed setup (e.g., tp_size, dp_replicate_size) with Weights & Biases for reproducibility and experiment analysis. Today, this is typically done manually on the user side. This change standardizes and automates that step.

This PR is from Issue #39882
@Rocketknight1 @MekkCyber

Thanks for you precious time for reviewing this PR.

Signed-off-by: WoosungMyung <dntjd517@naver.com>
@Rocketknight1

Copy link
Copy Markdown
Member

cc @SunMarc

@MekkCyber MekkCyber left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot 🤗 Sounds good ! left some nits

# Auto log Accelerate parallelism info to wandb.config
if self._initialized and state.is_world_process_zero and getattr(self._wandb, "run", None) is not None:
acc = getattr(model, "accelerator", None)
pc = getattr(acc, "parallelism_config", None) if acc is not None else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the if check is necessary since we can use getattr with NoneType as well in python

Suggested change
pc = getattr(acc, "parallelism_config", None) if acc is not None else None
pc = getattr(acc, "parallelism_config", None)

if self._initialized and state.is_world_process_zero and getattr(self._wandb, "run", None) is not None:
acc = getattr(model, "accelerator", None)
pc = getattr(acc, "parallelism_config", None) if acc is not None else None
sizes = getattr(pc, "_sizes", None) if pc is not None else None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sizes = getattr(pc, "_sizes", None) if pc is not None else None
sizes = getattr(pc, "_sizes", None)

@ArthurZucker

Copy link
Copy Markdown
Collaborator

Thanks for the PR, and sorry it didn't make it in! This branch is based on v4, and v5 is very different, so rather than rebasing we'd love to invite you to open a new PR against main using our latest tools and good practices:

Closing this one in the meantime, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants